package com.zs.service;

import com.zs.bean.User;
import com.zs.respository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhangshuqing on 2017/12/2.
 */

@Service
public class UserService {

    private Logger logger= LoggerFactory.getLogger(this.getClass());
    @Autowired
    private UserRepository userRepository;

    /**
     * 保存用户
     * @param userList
     */
    public void saveUser(List<User> userList){
        List<User> dbList=userRepository.insert(userList);
        logger.info("插入数据条数:{}",dbList.size());

    }

    /**
     * 查找所有的用户
     * @return
     */
    public List<User> findAllUser(){
        return userRepository.findAll();
    }


    public List<User> findUserByCode(String code){

        return userRepository.findByCode(code);
    }
}
